import React from 'react';

const LegendItem: React.FC<{ color: string; text: string; dashed?: boolean }> = ({ color, text, dashed }) => (
  <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
    <span style={{ width: 12, height: 12, background: color, border: '1px solid #999', display: 'inline-block' }} />
    <span>{text}</span>
    {dashed && <span style={{ marginLeft: 8, color: '#999' }}>(虚线)</span>}
  </div>
);

const CallGraphLegend: React.FC = () => {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12 }}>
      <LegendItem color="#e6f7ff" text="方法" />
      <LegendItem color="#f9f0ff" text="数据库表" />
      <LegendItem color="#f6ffed" text="入口方法" />
    </div>
  );
};

export default CallGraphLegend;

